<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vue示例</title>
<script src="https://cdn.bootcdn.net/ajax/libs/vue/3.2.40/vue.global.js"></script>
</head>
<body>
<div id="app">
    千米：<input type="text" v-model="kilometers">
    米：<input type="text" v-model="meters">
</div>
<script>
const app = Vue.createApp({
data() {
return {
    kilometers:0,
    meters:0
};
},
methods: {
},
computed: {
},
watch: {
    kilometers(val){
this.kilometers=val;
this.meters=this.kilometers*1000
    },
    meters(val){
this.meters=val;
this.kilometers=val/1000;
    }
}
}).mount("#app");
</script>
</body>
</html>